<?php require __DIR__.'/../top.phtml';?>
<link rel="stylesheet" href="/style/login.css" media="all">
<title><?php echo $this->title;?></title>
<meta name="description" content="<?php echo $this->description;?>" />
<meta name="keywords" content="<?php echo $this->keywords;?>" />
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>HookPHP</h2>
            <p><?php echo $this->title;?></p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="user" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="pass" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                <input type="hidden" name="referer" value="<?php echo $this->referer;?>" />
                <input type="hidden" name="token" value="<?php echo md5(uniqid(mt_rand(), true));?>" />
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
            </div>
            <div class="layui-trans layui-form-item layadmin-user-login-other">
                <label>社交账号登入</label>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>
            </div>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,form = layui.form;

        form.render();

        form.on('submit(LAY-user-login-submit)', function(obj){
            admin.req({
                url: layui.setter.base + 'api/login/v1'
                ,method: 'POST'
                ,data: obj.field
                ,done: function(res){
                    layer.msg(res.msg, {icon: 1, offset: '15px', time: 1000}, function(){
                        location.href = res.data.referer;
                    });
                }
                ,error: function(res){
                    layer.msg(res.msg, {icon: 5});
                }
            });
        });
    });
</script>
<?php require __DIR__.'/../bottom.phtml';?>